//
//  MTTopicViewController.m
//  MotorTravel
//
//  Created by zk on 16/9/12.
//  Copyright © 2016年 zk. All rights reserved.
//

#import "MTTopicViewController.h"
#import "MTTopicTableViewCell.h"
#import "MTTopicHeaderTableViewCell.h"


@interface MTTopicViewController ()
<
UITableViewDelegate,
UITableViewDataSource
>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *topicArray;///<选题
@property (nonatomic, strong) NSMutableArray *imageArray;///<轮播图
@property (nonatomic, strong) NSMutableArray *categoryArray;///<分类

@end

@implementation MTTopicViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self loadBaseUI];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)loadBaseUI {
    self.title = @"选题";
    
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.tableFooterView = [UIView new];

}

#pragma mark - tableview datasource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        MTTopicHeaderTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MTTopicHeaderTableViewCell"];
        [cell configWithImageArray:self.imageArray CategoryArray:self.categoryArray];
        return cell;
    } else {
        MTTopicTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MTTopicTableViewCell"];
        return cell;
    }
}

#pragma mark - tableview datasource

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 330;
    } else {
        return 129;
    }
}

#pragma mark - Setter & Getter 

- (NSMutableArray *)topicArray {
    if (!_topicArray) {
        _topicArray = [[NSMutableArray alloc] init];
    }
    return _topicArray;
}

- (NSMutableArray *)imageArray {
    if (!_imageArray) {
        _imageArray = [[NSMutableArray alloc] init];
    }
    return _imageArray;
}

- (NSMutableArray *)categoryArray {
    if (!_categoryArray) {
        _categoryArray = [[NSMutableArray alloc] init];
    }
    return _categoryArray;
}

@end
